package com.zy.openchat.core.model.user;

import android.os.Parcel;
import android.os.Parcelable;

import org.apache.commons.lang3.StringUtils;

public class OrgUserInfo implements Parcelable {
    public long uId;
    public String firstName;
    public String lastName;
    public String userName;
    public boolean isInternal;

    public String displayName() {
        return (StringUtils.isEmpty(firstName) ? "" : firstName) + (StringUtils.isEmpty(lastName) ? "" : lastName);
    }

    public OrgUserInfo() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.uId);
        dest.writeString(this.firstName);
        dest.writeString(this.lastName);
        dest.writeString(this.userName);
        dest.writeByte(this.isInternal ? (byte) 1 : (byte) 0);
    }

    protected OrgUserInfo(Parcel in) {
        this.uId = in.readLong();
        this.firstName = in.readString();
        this.lastName = in.readString();
        this.userName = in.readString();
        this.isInternal = in.readByte() != 0;
    }

    public static final Creator<OrgUserInfo> CREATOR = new Creator<OrgUserInfo>() {
        @Override
        public OrgUserInfo createFromParcel(Parcel source) {
            return new OrgUserInfo(source);
        }

        @Override
        public OrgUserInfo[] newArray(int size) {
            return new OrgUserInfo[size];
        }
    };
}
